package com.du.cloud.common.base.constant.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Optional;

@Getter
@RequiredArgsConstructor
public enum MenuType {
    MENU(1, "菜单"),
    PERMISSION(2, "权限")
    ;

    public final int type;

    public final String name;

    public static MenuType getMenuType(Integer type) {
        if (type == null) return null;
        Optional<MenuType> first = Arrays.stream(MenuType.values())
                .filter(i -> i.type == type)
                .findFirst();
        return first.orElse(null);
    }
}
